package com.intellagric.controller.module.sys_user_scene;

import com.intellagric.common.pojo.LayuiDataGridResult;
import com.intellagric.common.pojo.ResponseMessage;
import com.intellagric.pojo.SysUserSceneKey;
import com.intellagric.service.module.sys_user_scene.UserSceneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author: zhy
 * @email: 1269679946@qq.com
 * @Date: 2019/6/4
 * @DESC： 用户场景管理
 */
@Controller
public class UserSceneController {

    @Autowired
    private UserSceneService userSceneService;

    /**
     * 修改用户场景管理信息
     * @Param
     * @return ResponseMessage
     */
    @RequestMapping("/user/scene/edit")
    @ResponseBody
    public ResponseMessage edit(SysUserSceneKey userScene) {
        return userSceneService.addUserScene(userScene);
    }

    /**
     * 查询用户场景管理信息
     * @return SysUserSceneKey
     */
    @RequestMapping("/user/scene/{userId}")
    @ResponseBody
    public SysUserSceneKey get(@PathVariable String userId) {
        return userSceneService.getUSerSceneByUserId(userId);
    }

    /**
     * 根据用户id查询用户场景管理树信息
     * @return LayuiDataGridResult
     */
    @RequestMapping("/user/scene/tree")
    @ResponseBody
    public LayuiDataGridResult getTree(String userId) {
        return userSceneService.getUserScene(userId);
    }


    /**
     * 根据用户id查询用户场景下的设备列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/user/scene/equipment")
    @ResponseBody
    public LayuiDataGridResult getEquipment(String userId) {
        return userSceneService.getUserSceneEquipment(userId);
    }

}
